/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package splab.ufcg.edu.br.trace.gui;


/**
 * 
 * @author Arthur
 */
public class QueryFrame_Backup {
//
//	private TraceabilityFacade facade;
//
//	private Map<String, TraceQuery> mapQueries;
//
//	private boolean expand;
//
//	private TraceLinkList lastResult;
//
//	/**
//	 * Creates new form QueryFrame
//	 */
//	public QueryFrame_Backup(Map<String, TraceQuery> mapQueries) {
//		this.facade = TraceabilityFacade.getInstance();
//
//		this.mapQueries = mapQueries;
//
//		initComponents();
//
//		expand = false;
//
//		queryList.addListSelectionListener(new QuerySelectionListener());
//
//		setVisible(true);
//	}
//
//	/**
//	 * This method is called from within the constructor to initialize the form.
//	 * WARNING: Do NOT modify this code. The content of this method is always
//	 * regenerated by the Form Editor.
//	 */
//	@SuppressWarnings("unchecked")
//	// <editor-fold defaultstate="collapsed"
//	// <editor-fold defaultstate="collapsed"
//	// <editor-fold defaultstate="collapsed"
//	// <editor-fold defaultstate="collapsed"
//    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
//    private void initComponents() {
//
//        buttonPanel = new javax.swing.JPanel();
//        closeButton = new javax.swing.JButton();
//        runButton = new javax.swing.JButton();
//        runIcon = new javax.swing.JLabel();
//        closeIcon = new javax.swing.JLabel();
//        jSeparator1 = new javax.swing.JSeparator();
//        messageLabel = new javax.swing.JLabel();
//        queryFunctionalitiesPanel = new javax.swing.JPanel();
//        queryPanel = new javax.swing.JScrollPane();
//        queryList = new javax.swing.JList();
//        queryParameterPanel = new javax.swing.JScrollPane();
//        queryParameterTextArea = new javax.swing.JTextArea();
//        queryResultPanel = new javax.swing.JPanel();
//        filterFieldComboBox = new javax.swing.JComboBox();
//        filterValueComboBox = new javax.swing.JComboBox();
//        filterButton = new javax.swing.JButton();
//        
//        
//        representationPanel = new javax.swing.JPanel();
//        expandCollapseButton = new javax.swing.JButton();
//        treePanel = new javax.swing.JScrollPane();
//        traceTree = new javax.swing.JTree();
//
//        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
//
//        buttonPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
//
//        closeButton.setText("Close");
//        closeButton.addActionListener(new java.awt.event.ActionListener() {
//            public void actionPerformed(java.awt.event.ActionEvent evt) {
//                closeButtonActionPerformed(evt);
//            }
//        });
//
//        runButton.setText("Run Query");
//        runButton.addActionListener(new java.awt.event.ActionListener() {
//            public void actionPerformed(java.awt.event.ActionEvent evt) {
//                runButtonActionPerformed(evt);
//            }
//        });
//
//        runIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/run.png"))); // NOI18N
//        runIcon.setPreferredSize(new java.awt.Dimension(27, 27));
//
//        closeIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/exit.png"))); // NOI18N
//        closeIcon.setPreferredSize(new java.awt.Dimension(27, 27));
//
//        javax.swing.GroupLayout buttonPanelLayout = new javax.swing.GroupLayout(buttonPanel);
//        buttonPanel.setLayout(buttonPanelLayout);
//        buttonPanelLayout.setHorizontalGroup(
//            buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGroup(buttonPanelLayout.createSequentialGroup()
//                .addContainerGap()
//                .addGroup(buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//                    .addComponent(messageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
//                    .addGroup(buttonPanelLayout.createSequentialGroup()
//                        .addComponent(runIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
//                        .addComponent(runButton)
//                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
//                        .addComponent(closeIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
//                        .addComponent(closeButton))
//                    .addComponent(jSeparator1))
//                .addContainerGap())
//        );
//        buttonPanelLayout.setVerticalGroup(
//            buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup()
//                .addContainerGap()
//                .addComponent(messageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
//                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
//                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
//                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
//                .addGroup(buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
//                    .addComponent(runButton)
//                    .addComponent(runIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//                    .addComponent(closeIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//                    .addComponent(closeButton))
//                .addContainerGap())
//        );
//
//        queryFunctionalitiesPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
//
//        queryPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Available Queries"));
//
//        queryList.setModel(new javax.swing.AbstractListModel() {
//            Set<String> queriesSet = mapQueries.keySet();
//            String[] queriesArray = queriesSet.toArray(new String[0]);
//            public int getSize() { return queriesArray.length; }
//            public Object getElementAt(int i) { return queriesArray[i]; }
//        });
//        queryPanel.setViewportView(queryList);
//
//        queryParameterPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Edit Query Parameters"));
//
//        queryParameterTextArea.setColumns(20);
//        queryParameterTextArea.setRows(5);
//        queryParameterPanel.setViewportView(queryParameterTextArea);
//
//        javax.swing.GroupLayout queryFunctionalitiesPanelLayout = new javax.swing.GroupLayout(queryFunctionalitiesPanel);
//        queryFunctionalitiesPanel.setLayout(queryFunctionalitiesPanelLayout);
//        queryFunctionalitiesPanelLayout.setHorizontalGroup(
//            queryFunctionalitiesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGroup(queryFunctionalitiesPanelLayout.createSequentialGroup()
//                .addContainerGap()
//                .addGroup(queryFunctionalitiesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//                    .addComponent(queryPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
//                    .addComponent(queryParameterPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
//                .addContainerGap())
//        );
//        queryFunctionalitiesPanelLayout.setVerticalGroup(
//            queryFunctionalitiesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGroup(queryFunctionalitiesPanelLayout.createSequentialGroup()
//                .addContainerGap()
//                .addComponent(queryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)
//                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
//                .addComponent(queryParameterPanel)
//                .addContainerGap())
//        );
//
//        queryResultPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
//
//        filterFieldComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select" }));
//        filterFieldComboBox.addActionListener(new java.awt.event.ActionListener() {
//            public void actionPerformed(java.awt.event.ActionEvent evt) {
//                filterFieldComboBoxActionPerformed(evt);
//            }
//        });
//
//        filterValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select" }));
//
//        filterButton.setText("Filter");
//        filterButton.setPreferredSize(new java.awt.Dimension(76, 27));
//        filterButton.addActionListener(new java.awt.event.ActionListener() {
//            public void actionPerformed(java.awt.event.ActionEvent evt) {
//                filterButtonActionPerformed(evt);
//            }
//        });
//
//        javax.swing.GroupLayout queryResultPanelLayout = new javax.swing.GroupLayout(queryResultPanel);
//        queryResultPanel.setLayout(queryResultPanelLayout);
//        queryResultPanelLayout.setHorizontalGroup(
//            queryResultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGroup(queryResultPanelLayout.createSequentialGroup()
//                .addContainerGap()
//                .addComponent(filterFieldComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
//                .addGap(62, 62, 62)
//                .addComponent(filterValueComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
//                .addGap(74, 74, 74)
//                .addComponent(filterButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//                .addContainerGap())
//        );
//        queryResultPanelLayout.setVerticalGroup(
//            queryResultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, queryResultPanelLayout.createSequentialGroup()
//                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
//                .addGroup(queryResultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
//                    .addComponent(filterFieldComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//                    .addComponent(filterValueComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//                    .addComponent(filterButton, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
//                .addContainerGap())
//        );
//
//        representationPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
//
//        expandCollapseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/expand.gif")));
//        expandCollapseButton.setSize(new java.awt.Dimension(27, 27));
//        expandCollapseButton.addActionListener(new java.awt.event.ActionListener() {
//            public void actionPerformed(java.awt.event.ActionEvent evt) {
//                expandCollapseButtonActionPerformed(evt);
//            }
//        });
//
//        traceTree.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Retrieved Trace Links"));
//        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("Trace Links");
//        traceTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
//        traceTree.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
//        treePanel.setViewportView(traceTree);
//
//        javax.swing.GroupLayout representationPanelLayout = new javax.swing.GroupLayout(representationPanel);
//        representationPanel.setLayout(representationPanelLayout);
//        representationPanelLayout.setHorizontalGroup(
//            representationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, representationPanelLayout.createSequentialGroup()
//                .addGap(0, 413, Short.MAX_VALUE)
//                .addComponent(expandCollapseButton))
//            .addGroup(representationPanelLayout.createSequentialGroup()
//                .addContainerGap()
//                .addComponent(treePanel)
//                .addContainerGap())
//        );
//        representationPanelLayout.setVerticalGroup(
//            representationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, representationPanelLayout.createSequentialGroup()
//                .addContainerGap()
//                .addComponent(treePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
//                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
//                .addComponent(expandCollapseButton)
//                .addContainerGap())
//        );
//
//        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
//        getContentPane().setLayout(layout);
//        layout.setHorizontalGroup(
//            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
//                .addContainerGap()
//                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//                    .addGroup(layout.createSequentialGroup()
//                        .addComponent(queryFunctionalitiesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
//                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//                            .addComponent(representationPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
//                            .addComponent(queryResultPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
//                    .addComponent(buttonPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
//                .addContainerGap())
//        );
//        layout.setVerticalGroup(
//            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGroup(layout.createSequentialGroup()
//                .addContainerGap()
//                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
//                    .addGroup(layout.createSequentialGroup()
//                        .addComponent(representationPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
//                        .addComponent(queryResultPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
//                    .addComponent(queryFunctionalitiesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
//                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
//                .addComponent(buttonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
//        );
//
//        pack();
//    }// </editor-fold>//GEN-END:initComponents
//
//	@SuppressWarnings("unchecked")
//	private void filterFieldComboBoxActionPerformed(
//			java.awt.event.ActionEvent evt) {// GEN-FIRST:event_filterFieldComboBoxActionPerformed
//
//		int selectedIndex = filterFieldComboBox.getSelectedIndex();
//
//		switch (selectedIndex) {
//		case 0:
//			filterValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(
//					new String[] { "Select" }));
//			break;
//
//		case 1:
//
//			Set<String> requirementsList = lastResult.getRequirements();
//
//			filterValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(
//					requirementsList.toArray()));
//
//			break;
//
//		case 2:
//
//			Set<String> semanticList = lastResult.getSemantics();
//
//			filterValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(
//					semanticList.toArray()));
//
//			break;
//
//		case 3:
//
//			Set<String> typesList = lastResult.getArtifactTypes();
//
//			filterValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(
//					typesList.toArray()));
//
//			break;
//
//		case 4:
//
//			Set<String> artifactsList = lastResult.getArtifacts();
//
//			filterValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(
//					artifactsList.toArray()));
//
//			break;
//
//		default:
//			filterValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(
//					new String[] { "Select" }));
//			break;
//		}
//
//	}// GEN-LAST:event_filterFieldComboBoxActionPerformed
//
//	private void expandCollapseButtonActionPerformed(
//			java.awt.event.ActionEvent evt) {// GEN-FIRST:event_expandCollapseButtonActionPerformed
//		DefaultTreeModel model = (DefaultTreeModel) traceTree.getModel();
//		DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
//
//		expand = !expand;
//
//		if (expand) {
//			expandCollapseButton.setIcon(new javax.swing.ImageIcon(getClass()
//					.getResource("/icons/collapse.gif")));
//
//			for (int i = 0; i < traceTree.getRowCount(); i++) {
//				traceTree.expandRow(i);
//			}
//		} else {
//			expandCollapseButton.setIcon(new javax.swing.ImageIcon(getClass()
//					.getResource("/icons/expand.gif")));
//
//			for (int i = 0; i < traceTree.getRowCount(); i++) {
//				traceTree.collapseRow(i);
//			}
//		}
//		// model.reload(root);
//	}// GEN-LAST:event_expandCollapseButtonActionPerformed
//
//	private void filterButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_filterButtonActionPerformed
//
//		DefaultTreeModel model = (DefaultTreeModel) traceTree.getModel();
//		DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
//		root.removeAllChildren();
//		boolean result = false;
//		int size = 0;
//		long startTime = System.currentTimeMillis();
//
//		try {
//
//			TraceLinkList filteredTraces = new TraceLinkList();
//			List<TraceLink> relatedTraces = new ArrayList<TraceLink>();
//
//			int selectedIndex = filterFieldComboBox.getSelectedIndex();
//			String selectedValue = filterValueComboBox.getSelectedItem()
//					.toString();
//
//			if (lastResult != null) {
//				for (TraceLink traceLink : lastResult.getTraceLinks()) {
//					switch (selectedIndex) {
//					case 1:
//						if (traceLink.getRequirement().equals(selectedValue)) {
//							relatedTraces.add(traceLink);
//						}
//						break;
//
//					case 2:
//						if (traceLink.getSemantic().equals(selectedValue)) {
//							relatedTraces.add(traceLink);
//						}
//						break;
//
//					case 3:
//						if (traceLink.getArtifactType().equals(selectedValue)) {
//							relatedTraces.add(traceLink);
//						}
//						break;
//
//					case 4:
//						if (traceLink.getArtifact().equals(selectedValue)) {
//							relatedTraces.add(traceLink);
//						}
//						break;
//					default:
//						break;
//					}
//				}
//
//			}
//
//			filteredTraces.setTraceLinks(relatedTraces);
//			size = relatedTraces.size();
//
//			Set<String> typesNodes = filteredTraces.getArtifactTypes();
//			Set<String> semanticNodes = filteredTraces.getSemantics();
//			Set<String> requirementNodes = filteredTraces.getRequirements();
//
//			for (String requirementNode : requirementNodes) {
//
//				DefaultMutableTreeNode requirement = new DefaultMutableTreeNode(
//						requirementNode);
//
//				for (String semanticNode : semanticNodes) {
//					DefaultMutableTreeNode semantic = new DefaultMutableTreeNode(
//							semanticNode);
//
//					for (String artifactTypeNode : typesNodes) {
//
//						DefaultMutableTreeNode type = new DefaultMutableTreeNode(
//								artifactTypeNode);
//
//						relatedTraces = filteredTraces
//								.filterByRequirementSemanticAndType(
//										requirementNode, semanticNode,
//										artifactTypeNode);
//
//						for (TraceLink traceLink : relatedTraces) {
//
//							DefaultMutableTreeNode artifact = new DefaultMutableTreeNode(
//									traceLink.getArtifact());
//							type.add(artifact);
//						}
//
//						semantic.add(type);
//
//					}
//					requirement.add(semantic);
//				}
//				root.add(requirement);
//			}
//
//			result = true;
//
//		} catch (Exception ex) {
//			result = false;
//		}
//		long endTime = System.currentTimeMillis();
//		model.reload(root);
//		expand = false;
//
//		expandCollapseButton.setIcon(new javax.swing.ImageIcon(getClass()
//				.getResource("/icons/expand.gif")));
//
//		long duration = endTime - startTime;
//
//		if (result) {
//			messageLabel.setIcon(new javax.swing.ImageIcon(getClass()
//					.getResource("/icons/success.png")));
//			StringBuilder message = new StringBuilder();
//			message.append("Trace links filtered successfully. ");
//			message.append(size);
//			message.append(" trace links found. ");
//			message.append(duration);
//			message.append(" ms");
//
//			messageLabel.setText(message.toString());
//		} else {
//			messageLabel.setIcon(new javax.swing.ImageIcon(getClass()
//					.getResource("/icons/alert.png")));
//			messageLabel
//					.setText("Error while trying to filter trace links. See log for details");
//		}
//
//		
//
//	}// GEN-LAST:event_filterButtonActionPerformed
//
//	private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_closeButtonActionPerformed
//		this.dispose();
//	}// GEN-LAST:event_closeButtonActionPerformed
//
//	private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_runButtonActionPerformed
//
//		DefaultTreeModel model = (DefaultTreeModel) traceTree.getModel();
//		DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
//		root.removeAllChildren();
//		boolean result = false;
//		int size = 0;
//		long startTime = System.currentTimeMillis();
//
//		try {
//
//			String query = queryParameterTextArea.getText();
//			String[] split = query.split(":", 2);
//
//			QueryParameter param = new QueryParameter();
//			param.setField(split[0]);
//			param.setValue(split[1]);
//
//			TraceLinkList traceLinks = this.facade.queryTraceLinks(param);
//			size = traceLinks.getTraceLinks().size();
//
//			Set<String> typesNodes = traceLinks.getArtifactTypes();
//			Set<String> semanticNodes = traceLinks.getSemantics();
//			Set<String> requirementNodes = traceLinks.getRequirements();
//
//			for (String requirementNode : requirementNodes) {
//
//				DefaultMutableTreeNode requirement = new DefaultMutableTreeNode(
//						requirementNode);
//
//				for (String semanticNode : semanticNodes) {
//					DefaultMutableTreeNode semantic = new DefaultMutableTreeNode(
//							semanticNode);
//
//					for (String artifactTypeNode : typesNodes) {
//
//						DefaultMutableTreeNode type = new DefaultMutableTreeNode(
//								artifactTypeNode);
//
//						List<TraceLink> relatedTraces = traceLinks
//								.filterByRequirementSemanticAndType(
//										requirementNode, semanticNode,
//										artifactTypeNode);
//
//						for (TraceLink traceLink : relatedTraces) {
//
//							DefaultMutableTreeNode artifact = new DefaultMutableTreeNode(
//									traceLink.getArtifact());
//							type.add(artifact);
//						}
//
//						semantic.add(type);
//
//					}
//					requirement.add(semantic);
//				}
//				root.add(requirement);
//			}
//
//			result = true;
//			this.updateFilterButtons(traceLinks);
//			this.lastResult = traceLinks;
//		} catch (Exception ex) {
//			result = false;
//		}
//
//		model.reload(root);
//		long endTime = System.currentTimeMillis();
//
//		expand = false;
//
//		expandCollapseButton.setIcon(new javax.swing.ImageIcon(getClass()
//				.getResource("/icons/expand.gif")));
//
//		long duration = endTime - startTime;
//
//		if (result) {
//			messageLabel.setIcon(new javax.swing.ImageIcon(getClass()
//					.getResource("/icons/success.png")));
//			StringBuilder message = new StringBuilder();
//			message.append("Trace links queried successfully. ");
//			message.append(size);
//			message.append(" trace links found. ");
//			message.append(duration);
//			message.append(" ms");
//
//			messageLabel.setText(message.toString());
//		} else {
//			messageLabel.setIcon(new javax.swing.ImageIcon(getClass()
//					.getResource("/icons/alert.png")));
//			messageLabel
//					.setText("Error while trying to query trace links. See log for details");
//		}
//
//	}// GEN-LAST:event_runButtonActionPerformed
//
//    // Variables declaration - do not modify//GEN-BEGIN:variables
//    private javax.swing.JPanel buttonPanel;
//    private javax.swing.JButton closeButton;
//    private javax.swing.JLabel closeIcon;
//    private javax.swing.JButton expandCollapseButton;
//    private javax.swing.JButton filterButton;
//    private javax.swing.JComboBox filterFieldComboBox;
//    private javax.swing.JComboBox filterValueComboBox;
//    private javax.swing.JSeparator jSeparator1;
//    private javax.swing.JLabel messageLabel;
//    private javax.swing.JPanel queryFunctionalitiesPanel;
//    private javax.swing.JList queryList;
//    private javax.swing.JScrollPane queryPanel;
//    private javax.swing.JScrollPane queryParameterPanel;
//    private javax.swing.JTextArea queryParameterTextArea;
//    private javax.swing.JPanel queryResultPanel;
//    private javax.swing.JPanel representationPanel;
//    private javax.swing.JButton runButton;
//    private javax.swing.JLabel runIcon;
//    private javax.swing.JTree traceTree;
//    private javax.swing.JScrollPane treePanel;
//    // End of variables declaration//GEN-END:variables
//
//	private void updateFilterButtons(TraceLinkList traceLinks) {
//
//		filterFieldComboBox.setModel(new javax.swing.DefaultComboBoxModel(
//				new String[] { "Select",
//						ApacheSolrJFieldEnum.REQUIREMENT.toString(),
//						ApacheSolrJFieldEnum.SEMANTIC.toString(),
//						ApacheSolrJFieldEnum.ARTIFACT_TYPE.toString(),
//						ApacheSolrJFieldEnum.ARTIFACT.toString() }));
//
//		filterValueComboBox.setModel(new javax.swing.DefaultComboBoxModel(
//				new String[] { "Select" }));
//
//	}
//
//	class QuerySelectionListener implements ListSelectionListener {
//
//		public void valueChanged(ListSelectionEvent e) {
//
//			javax.swing.JList lsm = (javax.swing.JList) e.getSource();
//
//			int curretIndex = lsm.getSelectedIndex();
//			String key = queryList.getModel().getElementAt(curretIndex)
//					.toString();
//			TraceQuery query = mapQueries.get(key);
//
//			queryParameterTextArea.setText("");
//
//			int i = 0;
//			for (QueryParameter param : query.getParameters()) {
//
//				if (i > 0) {
//					queryParameterTextArea.append(System.lineSeparator());
//				}
//				queryParameterTextArea.append(param.getField());
//				queryParameterTextArea.append(":");
//				queryParameterTextArea.append("<value>");
//				i++;
//			}
//
//			messageLabel.setIcon(new javax.swing.ImageIcon(getClass()
//					.getResource("/icons/warning.png")));
//			messageLabel.setText("Change <value> tag(s) to desired value(s)");
//
//		}
//
//	}

}
